]>
git.proxmox.com Git - mirror_frr.git/blob - lib/command_match.c
2 * Input matching routines for CLI backend.
5 * Copyright (C) 2016 Cumulus Networks, Inc.
7 * This file is part of GNU Zebra.
9 * GNU Zebra is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
14 * GNU Zebra is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; see the file COPYING; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "command_match.h"
29 DEFINE_MTYPE_STATIC(LIB
, CMD_MATCHSTACK
, "Command Match Stack")
37 #define trace_matcher(...) \
40 fprintf(stderr, __VA_ARGS__); \
43 /* matcher helper prototypes */
44 static int add_nexthops(struct list
*, struct graph_node
*,
45 struct graph_node
**, size_t);
47 static enum matcher_rv
command_match_r(struct graph_node
*, vector
,
48 unsigned int, struct graph_node
**,
51 static int score_precedence(enum cmd_token_type
);
53 static enum match_type
min_match_level(enum cmd_token_type
);
55 static void del_arglist(struct list
*);
57 static struct cmd_token
*disambiguate_tokens(struct cmd_token
*,
58 struct cmd_token
*, char *);
60 static struct list
*disambiguate(struct list
*, struct list
*, vector
,
63 int compare_completions(const void *, const void *);
65 /* token matcher prototypes */
66 static enum match_type
match_token(struct cmd_token
*, char *);
68 static enum match_type
match_ipv4(const char *);
70 static enum match_type
match_ipv4_prefix(const char *);
72 static enum match_type
match_ipv6_prefix(const char *, bool);
74 static enum match_type
match_range(struct cmd_token
*, const char *);
76 static enum match_type
match_word(struct cmd_token
*, const char *);
78 static enum match_type
match_variable(struct cmd_token
*, const char *);
80 static enum match_type
match_mac(const char *, bool);
82 enum matcher_rv
command_match(struct graph
*cmdgraph
, vector vline
,
83 struct list
**argv
, const struct cmd_element
**el
)
85 struct graph_node
*stack
[CMD_ARGC_MAX
];
86 enum matcher_rv status
;
89 // prepend a dummy token to match that pesky start node
90 vector vvline
= vector_init(vline
->alloced
+ 1);
91 vector_set_index(vvline
, 0, (void *)XSTRDUP(MTYPE_TMP
, "dummy"));
92 memcpy(vvline
->index
+ 1, vline
->index
,
93 sizeof(void *) * vline
->alloced
);
94 vvline
->active
= vline
->active
+ 1;
96 struct graph_node
*start
= vector_slot(cmdgraph
->nodes
, 0);
97 status
= command_match_r(start
, vvline
, 0, stack
, argv
);
98 if (status
== MATCHER_OK
) { // successful match
99 struct listnode
*head
= listhead(*argv
);
100 struct listnode
*tail
= listtail(*argv
);
105 // delete dummy start node
106 cmd_token_del((struct cmd_token
*)head
->data
);
107 list_delete_node(*argv
, head
);
109 // get cmd_element out of list tail
110 *el
= listgetdata(tail
);
111 list_delete_node(*argv
, tail
);
113 // now argv is an ordered list of cmd_token matching the user
114 // input, with each cmd_token->arg holding the corresponding
123 trace_matcher("No match\n");
125 trace_matcher("Matched command\n->string %s\n->desc %s\n",
126 (*el
)->string
, (*el
)->doc
);
129 // free the leader token we alloc'd
130 XFREE(MTYPE_TMP
, vector_slot(vvline
, 0));
138 * Builds an argument list given a DFA and a matching input line.
140 * First the function determines if the node it is passed matches the first
141 * token of input. If it does not, it returns NULL (MATCHER_NO_MATCH). If it
142 * does match, then it saves the input token as the head of an argument list.
144 * The next step is to see if there is further input in the input line. If
145 * there is not, the current node's children are searched to see if any of them
146 * are leaves (type END_TKN). If this is the case, then the bottom of the
147 * recursion stack has been reached, the leaf is pushed onto the argument list,
148 * the current node is pushed, and the resulting argument list is
149 * returned (MATCHER_OK). If it is not the case, NULL is returned, indicating
150 * that there is no match for the input along this path (MATCHER_INCOMPLETE).
152 * If there is further input, then the function recurses on each of the current
153 * node's children, passing them the input line minus the token that was just
154 * matched. For each child, the return value of the recursive call is
155 * inspected. If it is null, then there is no match for the input along the
156 * subgraph headed by that child. If it is not null, then there is at least one
157 * input match in that subgraph (more on this in a moment).
159 * If a recursive call on a child returns a non-null value, then it has matched
160 * the input given it on the subgraph that starts with that child. However, due
161 * to the flexibility of the grammar, it is sometimes the case that two or more
162 * child graphs match the same input (two or more of the recursive calls have
163 * non-NULL return values). This is not a valid state, since only one true
164 * match is possible. In order to resolve this conflict, the function keeps a
165 * reference to the child node that most specifically matches the input. This
166 * is done by assigning each node type a precedence. If a child is found to
167 * match the remaining input, then the precedence values of the current
168 * best-matching child and this new match are compared. The node with higher
169 * precedence is kept, and the other match is discarded. Due to the recursive
170 * nature of this function, it is only necessary to compare the precedence of
171 * immediate children, since all subsequent children will already have been
172 * disambiguated in this way.
174 * In the event that two children are found to match with the same precedence,
175 * then the input is ambiguous for the passed cmd_element and NULL is returned.
177 * @param[in] start the start node.
178 * @param[in] vline the vectorized input line.
179 * @param[in] n the index of the first input token.
180 * @return A linked list of n elements. The first n-1 elements are pointers to
181 * struct cmd_token and represent the sequence of tokens matched by the input.
182 * The ->arg field of each token points to a copy of the input matched on it.
183 * The final nth element is a pointer to struct cmd_element, which is the
184 * command that was matched.
186 * If no match was found, the return value is NULL.
188 static enum matcher_rv
command_match_r(struct graph_node
*start
, vector vline
,
190 struct graph_node
**stack
,
191 struct list
**currbest
)
193 assert(n
< vector_active(vline
));
195 enum matcher_rv status
= MATCHER_NO_MATCH
;
197 // get the minimum match level that can count as a full match
198 struct cmd_token
*token
= start
->data
;
199 enum match_type minmatch
= min_match_level(token
->type
);
201 /* check history/stack of tokens
202 * this disallows matching the same one more than once if there is a
203 * circle in the graph (used for keyword arguments) */
204 if (n
== CMD_ARGC_MAX
)
205 return MATCHER_NO_MATCH
;
206 if (!token
->allowrepeat
)
207 for (size_t s
= 0; s
< n
; s
++)
208 if (stack
[s
] == start
)
209 return MATCHER_NO_MATCH
;
211 // get the current operating input token
212 char *input_token
= vector_slot(vline
, n
);
215 fprintf(stdout
, "\"%-20s\" matches \"%-30s\" ? ", input_token
,
217 enum match_type mt
= match_token(token
, input_token
);
218 fprintf(stdout
, "type: %d ", token
->type
);
219 fprintf(stdout
, "min: %d - ", minmatch
);
222 fprintf(stdout
, "trivial_match ");
225 fprintf(stdout
, "no_match ");
228 fprintf(stdout
, "partly_match ");
231 fprintf(stdout
, "exact_match ");
235 fprintf(stdout
, " MATCH");
236 fprintf(stdout
, "\n");
239 // if we don't match this node, die
240 if (match_token(token
, input_token
) < minmatch
)
241 return MATCHER_NO_MATCH
;
245 // pointers for iterating linklist
247 struct graph_node
*gn
;
249 // get all possible nexthops
250 struct list
*next
= list_new();
251 add_nexthops(next
, start
, NULL
, 0);
253 // determine the best match
254 for (ALL_LIST_ELEMENTS_RO(next
, ln
, gn
)) {
255 // if we've matched all input we're looking for END_TKN
256 if (n
+ 1 == vector_active(vline
)) {
257 struct cmd_token
*tok
= gn
->data
;
258 if (tok
->type
== END_TKN
) {
259 // if more than one END_TKN in the follow set
261 status
= MATCHER_AMBIGUOUS
;
266 *currbest
= list_new();
267 // node should have one child node with the
269 struct graph_node
*leaf
=
270 vector_slot(gn
->to
, 0);
271 // last node in the list will hold the
272 // cmd_element; this is important because
273 // list_delete() expects that all nodes have
274 // the same data type, so when deleting this
275 // list the last node must be manually deleted
276 struct cmd_element
*el
= leaf
->data
;
277 listnode_add(*currbest
, el
);
279 (void (*)(void *)) & cmd_token_del
;
280 // do not break immediately; continue walking
281 // through the follow set to ensure that there
282 // is exactly one END_TKN
287 // else recurse on candidate child node
288 struct list
*result
= NULL
;
289 enum matcher_rv rstat
=
290 command_match_r(gn
, vline
, n
+ 1, stack
, &result
);
292 // save the best match
293 if (result
&& *currbest
) {
294 // pick the best of two matches
295 struct list
*newbest
=
296 disambiguate(*currbest
, result
, vline
, n
+ 1);
298 // current best and result are ambiguous
300 status
= MATCHER_AMBIGUOUS
;
301 // current best is still the best, but ambiguous
302 else if (newbest
== *currbest
303 && status
== MATCHER_AMBIGUOUS
)
304 status
= MATCHER_AMBIGUOUS
;
305 // result is better, but also ambiguous
306 else if (newbest
== result
307 && rstat
== MATCHER_AMBIGUOUS
)
308 status
= MATCHER_AMBIGUOUS
;
309 // one or the other is superior and not ambiguous
313 // delete the unnecessary result
314 struct list
*todelete
=
315 ((newbest
&& newbest
== result
) ? *currbest
317 del_arglist(todelete
);
319 *currbest
= newbest
? newbest
: *currbest
;
323 } else if (!*currbest
) {
324 status
= MAX(rstat
, status
);
328 // copy token, set arg and prepend to currbest
329 struct cmd_token
*token
= start
->data
;
330 struct cmd_token
*copy
= cmd_token_dup(token
);
331 copy
->arg
= XSTRDUP(MTYPE_CMD_ARG
, input_token
);
332 listnode_add_before(*currbest
, (*currbest
)->head
, copy
);
333 } else if (n
+ 1 == vector_active(vline
) && status
== MATCHER_NO_MATCH
)
334 status
= MATCHER_INCOMPLETE
;
337 list_delete_and_null(&next
);
342 static void stack_del(void *val
)
344 XFREE(MTYPE_CMD_MATCHSTACK
, val
);
347 enum matcher_rv
command_complete(struct graph
*graph
, vector vline
,
348 struct list
**completions
)
350 // pointer to next input token to match
355 list_new(), // current nodes to match input token against
356 *next
= list_new(); // possible next hops after current input
358 current
->del
= next
->del
= stack_del
;
360 // pointers used for iterating lists
361 struct graph_node
**gstack
, **newstack
;
362 struct listnode
*node
;
364 // add all children of start node to list
365 struct graph_node
*start
= vector_slot(graph
->nodes
, 0);
366 add_nexthops(next
, start
, &start
, 0);
369 for (idx
= 0; idx
< vector_active(vline
) && next
->count
> 0; idx
++) {
370 list_delete_and_null(¤t
);
373 next
->del
= stack_del
;
375 input_token
= vector_slot(vline
, idx
);
377 int exact_match_exists
= 0;
378 for (ALL_LIST_ELEMENTS_RO(current
, node
, gstack
))
379 if (!exact_match_exists
)
381 (match_token(gstack
[0]->data
,
387 for (ALL_LIST_ELEMENTS_RO(current
, node
, gstack
)) {
388 struct cmd_token
*token
= gstack
[0]->data
;
390 if (token
->attr
== CMD_ATTR_HIDDEN
391 || token
->attr
== CMD_ATTR_DEPRECATED
)
394 enum match_type minmatch
= min_match_level(token
->type
);
395 trace_matcher("\"%s\" matches \"%s\" (%d) ? ",
396 input_token
, token
->text
, token
->type
);
398 unsigned int last_token
=
399 (vector_active(vline
) - 1 == idx
);
400 enum match_type matchtype
=
401 match_token(token
, input_token
);
403 // occurs when last token is whitespace
405 trace_matcher("trivial_match\n");
407 newstack
= XMALLOC(MTYPE_CMD_MATCHSTACK
,
408 sizeof(struct graph_node
*));
409 /* we're not recursing here, just the first
411 newstack
[0] = gstack
[0];
412 listnode_add(next
, newstack
);
415 trace_matcher("trivial_match\n");
416 if (exact_match_exists
&& !last_token
)
420 trace_matcher("exact_match\n");
423 MTYPE_CMD_MATCHSTACK
,
424 sizeof(struct graph_node
*));
425 /* same as above, not recursing on this
427 newstack
[0] = gstack
[0];
428 listnode_add(next
, newstack
);
429 } else if (matchtype
>= minmatch
)
430 add_nexthops(next
, gstack
[0], gstack
,
434 trace_matcher("no_match\n");
441 * -----------------------------------------------------------------
442 * token = last input token processed
443 * idx = index in `command` of last token processed
444 * current = set of all transitions from the previous input token
445 * next = set of all nodes reachable from all nodes in `matched`
448 enum matcher_rv mrv
= idx
== vector_active(vline
) && next
->count
453 if (!MATCHER_ERROR(mrv
)) {
454 // extract cmd_token into list
455 *completions
= list_new();
456 for (ALL_LIST_ELEMENTS_RO(next
, node
, gstack
)) {
457 listnode_add(*completions
, gstack
[0]->data
);
461 list_delete_and_null(¤t
);
462 list_delete_and_null(&next
);
468 * Adds all children that are reachable by one parser hop to the given list.
469 * special tokens except END_TKN are treated as transparent.
471 * @param[in] list to add the nexthops to
472 * @param[in] node to start calculating nexthops from
473 * @param[in] stack listing previously visited nodes, if non-NULL.
474 * @param[in] stackpos how many valid entries are in stack
475 * @return the number of children added to the list
477 * NB: non-null "stack" means that new stacks will be added to "list" as
478 * output, instead of direct node pointers!
480 static int add_nexthops(struct list
*list
, struct graph_node
*node
,
481 struct graph_node
**stack
, size_t stackpos
)
484 struct graph_node
*child
;
485 struct graph_node
**nextstack
;
486 for (unsigned int i
= 0; i
< vector_active(node
->to
); i
++) {
487 child
= vector_slot(node
->to
, i
);
489 struct cmd_token
*token
= child
->data
;
490 if (!token
->allowrepeat
&& stack
) {
491 for (j
= 0; j
< stackpos
; j
++)
492 if (child
== stack
[j
])
497 if (token
->type
>= SPECIAL_TKN
&& token
->type
!= END_TKN
) {
498 added
+= add_nexthops(list
, child
, stack
, stackpos
);
502 MTYPE_CMD_MATCHSTACK
,
504 * sizeof(struct graph_node
*));
505 nextstack
[0] = child
;
506 memcpy(nextstack
+ 1, stack
,
507 stackpos
* sizeof(struct graph_node
*));
509 listnode_add(list
, nextstack
);
511 listnode_add(list
, child
);
520 * Determines the node types for which a partial match may count as a full
521 * match. Enables command abbrevations.
523 * @param[in] type node type
524 * @return minimum match level needed to for a token to fully match
526 static enum match_type
min_match_level(enum cmd_token_type type
)
529 // anything matches a start node, for the sake of recursion
532 // allowing words to partly match enables command abbreviation
541 * Assigns precedence scores to node types.
543 * @param[in] type node type to score
544 * @return precedence score
546 static int score_precedence(enum cmd_token_type type
)
549 // some of these are mutually exclusive, so they share
550 // the same precedence value
552 case IPV4_PREFIX_TKN
:
554 case IPV6_PREFIX_TKN
:
569 * Picks the better of two possible matches for a token.
571 * @param[in] first candidate node matching token
572 * @param[in] second candidate node matching token
573 * @param[in] token the token being matched
574 * @return the best-matching node, or NULL if the two are entirely ambiguous
576 static struct cmd_token
*disambiguate_tokens(struct cmd_token
*first
,
577 struct cmd_token
*second
,
580 // if the types are different, simply go off of type precedence
581 if (first
->type
!= second
->type
) {
582 int firstprec
= score_precedence(first
->type
);
583 int secndprec
= score_precedence(second
->type
);
584 if (firstprec
!= secndprec
)
585 return firstprec
< secndprec
? first
: second
;
590 // if they're the same, return the more exact match
591 enum match_type fmtype
= match_token(first
, input_token
);
592 enum match_type smtype
= match_token(second
, input_token
);
593 if (fmtype
!= smtype
)
594 return fmtype
> smtype
? first
: second
;
600 * Picks the better of two possible matches for an input line.
602 * @param[in] first candidate list of cmd_token matching vline
603 * @param[in] second candidate list of cmd_token matching vline
604 * @param[in] vline the input line being matched
605 * @param[in] n index into vline to start comparing at
606 * @return the best-matching list, or NULL if the two are entirely ambiguous
608 static struct list
*disambiguate(struct list
*first
, struct list
*second
,
609 vector vline
, unsigned int n
)
611 // doesn't make sense for these to be inequal length
612 assert(first
->count
== second
->count
);
613 assert(first
->count
== vector_active(vline
) - n
+ 1);
615 struct listnode
*fnode
= listhead(first
), *snode
= listhead(second
);
616 struct cmd_token
*ftok
= listgetdata(fnode
), *stok
= listgetdata(snode
),
619 // compare each token, if one matches better use that one
620 for (unsigned int i
= n
; i
< vector_active(vline
); i
++) {
621 char *token
= vector_slot(vline
, i
);
622 if ((best
= disambiguate_tokens(ftok
, stok
, token
)))
623 return best
== ftok
? first
: second
;
624 fnode
= listnextnode(fnode
);
625 snode
= listnextnode(snode
);
626 ftok
= listgetdata(fnode
);
627 stok
= listgetdata(snode
);
634 * Deletion function for arglist.
636 * Since list->del for arglists expects all listnode->data to hold cmd_token,
637 * but arglists have cmd_element as the data for the tail, this function
638 * manually deletes the tail before deleting the rest of the list as usual.
640 * The cmd_element at the end is *not* a copy. It is the one and only.
642 * @param list the arglist to delete
644 static void del_arglist(struct list
*list
)
646 // manually delete last node
647 struct listnode
*tail
= listtail(list
);
649 list_delete_node(list
, tail
);
651 // delete the rest of the list as usual
652 list_delete_and_null(&list
);
655 /*---------- token level matching functions ----------*/
657 static enum match_type
match_token(struct cmd_token
*token
, char *input_token
)
659 // nothing trivially matches everything
661 return trivial_match
;
663 switch (token
->type
) {
665 return match_word(token
, input_token
);
667 return match_ipv4(input_token
);
668 case IPV4_PREFIX_TKN
:
669 return match_ipv4_prefix(input_token
);
671 return match_ipv6_prefix(input_token
, false);
672 case IPV6_PREFIX_TKN
:
673 return match_ipv6_prefix(input_token
, true);
675 return match_range(token
, input_token
);
677 return match_variable(token
, input_token
);
679 return match_mac(input_token
, false);
681 return match_mac(input_token
, true);
688 #define IPV4_ADDR_STR "0123456789."
689 #define IPV4_PREFIX_STR "0123456789./"
691 static enum match_type
match_ipv4(const char *str
)
694 int dots
= 0, nums
= 0;
698 memset(buf
, 0, sizeof(buf
));
700 while (*str
!= '\0') {
705 if (*(str
+ 1) == '.')
708 if (*(str
+ 1) == '\0')
714 if (!isdigit((int)*str
))
723 strncpy(buf
, sp
, str
- sp
);
741 static enum match_type
match_ipv4_prefix(const char *str
)
748 memset(buf
, 0, sizeof(buf
));
750 while (*str
!= '\0' && *str
!= '/') {
755 if (*(str
+ 1) == '.' || *(str
+ 1) == '/')
758 if (*(str
+ 1) == '\0')
765 if (!isdigit((int)*str
))
774 strncpy(buf
, sp
, str
- sp
);
780 if (*(str
+ 1) == '\0')
785 } else if (*str
== '\0')
796 while (*str
!= '\0') {
797 if (!isdigit((int)*str
))
810 #define IPV6_ADDR_STR "0123456789abcdefABCDEF:."
811 #define IPV6_PREFIX_STR "0123456789abcdefABCDEF:./"
812 #define STATE_START 1
813 #define STATE_COLON 2
814 #define STATE_DOUBLE 3
817 #define STATE_SLASH 6
820 static enum match_type
match_ipv6_prefix(const char *str
, bool prefix
)
822 int state
= STATE_START
;
823 int colons
= 0, nums
= 0, double_colon
= 0;
825 const char *sp
= NULL
, *start
= str
;
831 if (strspn(str
, prefix
? IPV6_PREFIX_STR
: IPV6_ADDR_STR
)
835 while (*str
!= '\0' && state
!= STATE_MASK
) {
839 if (*(str
+ 1) != ':' && *(str
+ 1) != '\0')
851 if (*(str
+ 1) == '/')
853 else if (*(str
+ 1) == ':')
854 state
= STATE_DOUBLE
;
864 if (*(str
+ 1) == ':')
867 if (*(str
+ 1) != '\0' && *(str
+ 1) != '/')
871 if (*(str
+ 1) == '/')
881 if (*(str
+ 1) == ':' || *(str
+ 1) == '.'
882 || *(str
+ 1) == '\0' || *(str
+ 1) == '/') {
886 for (; sp
<= str
; sp
++)
892 if (*(str
+ 1) == ':')
894 else if (*(str
+ 1) == '.') {
895 if (colons
|| double_colon
)
899 } else if (*(str
+ 1) == '/')
907 if (*(str
+ 1) == '\0')
926 struct sockaddr_in6 sin6_dummy
;
927 int ret
= inet_pton(AF_INET6
, start
, &sin6_dummy
.sin6_addr
);
928 return ret
== 1 ? exact_match
: partly_match
;
931 if (state
< STATE_MASK
)
934 mask
= strtol(str
, &endptr
, 10);
938 if (mask
< 0 || mask
> 128)
944 static enum match_type
match_range(struct cmd_token
*token
, const char *str
)
946 assert(token
->type
== RANGE_TKN
);
951 val
= strtoll(str
, &endptr
, 10);
955 if (val
< token
->min
|| val
> token
->max
)
961 static enum match_type
match_word(struct cmd_token
*token
, const char *word
)
963 assert(token
->type
== WORD_TKN
);
965 // if the passed token is 0 length, partly match
969 // if the passed token is strictly a prefix of the full word, partly
971 if (strlen(word
) < strlen(token
->text
))
972 return !strncmp(token
->text
, word
, strlen(word
)) ? partly_match
975 // if they are the same length and exactly equal, exact match
976 else if (strlen(word
) == strlen(token
->text
))
977 return !strncmp(token
->text
, word
, strlen(word
)) ? exact_match
983 static enum match_type
match_variable(struct cmd_token
*token
, const char *word
)
985 assert(token
->type
== VARIABLE_TKN
);
989 #define MAC_CHARS "ABCDEFabcdef0123456789:"
991 static enum match_type
match_mac(const char *word
, bool prefix
)
993 /* 6 2-digit hex numbers separated by 5 colons */
994 size_t mac_explen
= 6 * 2 + 5;
995 /* '/' + 2-digit integer */
996 size_t mask_len
= 1 + 2;
999 unsigned int maskval
;
1002 if (strlen(word
) > mac_explen
+ (prefix
? mask_len
: 0))
1006 for (i
= 0; i
< mac_explen
; i
++) {
1007 if (word
[i
] == '\0' || !strchr(MAC_CHARS
, word
[i
]))
1009 if (((i
+ 1) % 3 == 0) != (word
[i
] == ':'))
1013 /* incomplete address */
1014 if (i
< mac_explen
&& word
[i
] == '\0')
1015 return partly_match
;
1016 else if (i
< mac_explen
)
1020 if (prefix
&& word
[i
] == '/') {
1021 if (word
[++i
] == '\0')
1022 return partly_match
;
1024 maskval
= strtoul(&word
[i
], &eptr
, 10);
1025 if (*eptr
!= '\0' || maskval
> 48)
1027 } else if (prefix
&& word
[i
] == '\0') {
1028 return partly_match
;
1029 } else if (prefix
) {