]>
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
);
102 // delete dummy start node
103 cmd_token_del((struct cmd_token
*)head
->data
);
104 list_delete_node(*argv
, head
);
106 // get cmd_element out of list tail
107 *el
= listgetdata(tail
);
108 list_delete_node(*argv
, tail
);
110 // now argv is an ordered list of cmd_token matching the user
111 // input, with each cmd_token->arg holding the corresponding
120 trace_matcher("No match\n");
122 trace_matcher("Matched command\n->string %s\n->desc %s\n",
123 (*el
)->string
, (*el
)->doc
);
126 // free the leader token we alloc'd
127 XFREE(MTYPE_TMP
, vector_slot(vvline
, 0));
135 * Builds an argument list given a DFA and a matching input line.
137 * First the function determines if the node it is passed matches the first
138 * token of input. If it does not, it returns NULL (MATCHER_NO_MATCH). If it
139 * does match, then it saves the input token as the head of an argument list.
141 * The next step is to see if there is further input in the input line. If
142 * there is not, the current node's children are searched to see if any of them
143 * are leaves (type END_TKN). If this is the case, then the bottom of the
144 * recursion stack has been reached, the leaf is pushed onto the argument list,
145 * the current node is pushed, and the resulting argument list is
146 * returned (MATCHER_OK). If it is not the case, NULL is returned, indicating
147 * that there is no match for the input along this path (MATCHER_INCOMPLETE).
149 * If there is further input, then the function recurses on each of the current
150 * node's children, passing them the input line minus the token that was just
151 * matched. For each child, the return value of the recursive call is
152 * inspected. If it is null, then there is no match for the input along the
153 * subgraph headed by that child. If it is not null, then there is at least one
154 * input match in that subgraph (more on this in a moment).
156 * If a recursive call on a child returns a non-null value, then it has matched
157 * the input given it on the subgraph that starts with that child. However, due
158 * to the flexibility of the grammar, it is sometimes the case that two or more
159 * child graphs match the same input (two or more of the recursive calls have
160 * non-NULL return values). This is not a valid state, since only one true
161 * match is possible. In order to resolve this conflict, the function keeps a
162 * reference to the child node that most specifically matches the input. This
163 * is done by assigning each node type a precedence. If a child is found to
164 * match the remaining input, then the precedence values of the current
165 * best-matching child and this new match are compared. The node with higher
166 * precedence is kept, and the other match is discarded. Due to the recursive
167 * nature of this function, it is only necessary to compare the precedence of
168 * immediate children, since all subsequent children will already have been
169 * disambiguated in this way.
171 * In the event that two children are found to match with the same precedence,
172 * then the input is ambiguous for the passed cmd_element and NULL is returned.
174 * @param[in] start the start node.
175 * @param[in] vline the vectorized input line.
176 * @param[in] n the index of the first input token.
177 * @return A linked list of n elements. The first n-1 elements are pointers to
178 * struct cmd_token and represent the sequence of tokens matched by the input.
179 * The ->arg field of each token points to a copy of the input matched on it.
180 * The final nth element is a pointer to struct cmd_element, which is the
181 * command that was matched.
183 * If no match was found, the return value is NULL.
185 static enum matcher_rv
command_match_r(struct graph_node
*start
, vector vline
,
187 struct graph_node
**stack
,
188 struct list
**currbest
)
190 assert(n
< vector_active(vline
));
192 enum matcher_rv status
= MATCHER_NO_MATCH
;
194 // get the minimum match level that can count as a full match
195 struct cmd_token
*token
= start
->data
;
196 enum match_type minmatch
= min_match_level(token
->type
);
198 /* check history/stack of tokens
199 * this disallows matching the same one more than once if there is a
200 * circle in the graph (used for keyword arguments) */
201 if (n
== CMD_ARGC_MAX
)
202 return MATCHER_NO_MATCH
;
203 if (!token
->allowrepeat
)
204 for (size_t s
= 0; s
< n
; s
++)
205 if (stack
[s
] == start
)
206 return MATCHER_NO_MATCH
;
208 // get the current operating input token
209 char *input_token
= vector_slot(vline
, n
);
212 fprintf(stdout
, "\"%-20s\" matches \"%-30s\" ? ", input_token
,
214 enum match_type mt
= match_token(token
, input_token
);
215 fprintf(stdout
, "type: %d ", token
->type
);
216 fprintf(stdout
, "min: %d - ", minmatch
);
219 fprintf(stdout
, "trivial_match ");
222 fprintf(stdout
, "no_match ");
225 fprintf(stdout
, "partly_match ");
228 fprintf(stdout
, "exact_match ");
232 fprintf(stdout
, " MATCH");
233 fprintf(stdout
, "\n");
236 // if we don't match this node, die
237 if (match_token(token
, input_token
) < minmatch
)
238 return MATCHER_NO_MATCH
;
242 // pointers for iterating linklist
244 struct graph_node
*gn
;
246 // get all possible nexthops
247 struct list
*next
= list_new();
248 add_nexthops(next
, start
, NULL
, 0);
250 // determine the best match
251 for (ALL_LIST_ELEMENTS_RO(next
, ln
, gn
)) {
252 // if we've matched all input we're looking for END_TKN
253 if (n
+ 1 == vector_active(vline
)) {
254 struct cmd_token
*tok
= gn
->data
;
255 if (tok
->type
== END_TKN
) {
256 // if more than one END_TKN in the follow set
258 status
= MATCHER_AMBIGUOUS
;
263 *currbest
= list_new();
264 // node should have one child node with the
266 struct graph_node
*leaf
=
267 vector_slot(gn
->to
, 0);
268 // last node in the list will hold the
269 // cmd_element; this is important because
270 // list_delete() expects that all nodes have
271 // the same data type, so when deleting this
272 // list the last node must be manually deleted
273 struct cmd_element
*el
= leaf
->data
;
274 listnode_add(*currbest
, el
);
276 (void (*)(void *)) & cmd_token_del
;
277 // do not break immediately; continue walking
278 // through the follow set to ensure that there
279 // is exactly one END_TKN
284 // else recurse on candidate child node
285 struct list
*result
= NULL
;
286 enum matcher_rv rstat
=
287 command_match_r(gn
, vline
, n
+ 1, stack
, &result
);
289 // save the best match
290 if (result
&& *currbest
) {
291 // pick the best of two matches
292 struct list
*newbest
=
293 disambiguate(*currbest
, result
, vline
, n
+ 1);
295 // current best and result are ambiguous
297 status
= MATCHER_AMBIGUOUS
;
298 // current best is still the best, but ambiguous
299 else if (newbest
== *currbest
300 && status
== MATCHER_AMBIGUOUS
)
301 status
= MATCHER_AMBIGUOUS
;
302 // result is better, but also ambiguous
303 else if (newbest
== result
304 && rstat
== MATCHER_AMBIGUOUS
)
305 status
= MATCHER_AMBIGUOUS
;
306 // one or the other is superior and not ambiguous
310 // delete the unnecessary result
311 struct list
*todelete
=
312 ((newbest
&& newbest
== result
) ? *currbest
314 del_arglist(todelete
);
316 *currbest
= newbest
? newbest
: *currbest
;
320 } else if (!*currbest
) {
321 status
= MAX(rstat
, status
);
325 // copy token, set arg and prepend to currbest
326 struct cmd_token
*token
= start
->data
;
327 struct cmd_token
*copy
= cmd_token_dup(token
);
328 copy
->arg
= XSTRDUP(MTYPE_CMD_ARG
, input_token
);
329 listnode_add_before(*currbest
, (*currbest
)->head
, copy
);
330 } else if (n
+ 1 == vector_active(vline
) && status
== MATCHER_NO_MATCH
)
331 status
= MATCHER_INCOMPLETE
;
334 list_delete_and_null(&next
);
339 static void stack_del(void *val
)
341 XFREE(MTYPE_CMD_MATCHSTACK
, val
);
344 enum matcher_rv
command_complete(struct graph
*graph
, vector vline
,
345 struct list
**completions
)
347 // pointer to next input token to match
352 list_new(), // current nodes to match input token against
353 *next
= list_new(); // possible next hops after current input
355 current
->del
= next
->del
= stack_del
;
357 // pointers used for iterating lists
358 struct graph_node
**gstack
, **newstack
;
359 struct listnode
*node
;
361 // add all children of start node to list
362 struct graph_node
*start
= vector_slot(graph
->nodes
, 0);
363 add_nexthops(next
, start
, &start
, 0);
366 for (idx
= 0; idx
< vector_active(vline
) && next
->count
> 0; idx
++) {
367 list_delete_and_null(¤t
);
370 next
->del
= stack_del
;
372 input_token
= vector_slot(vline
, idx
);
374 int exact_match_exists
= 0;
375 for (ALL_LIST_ELEMENTS_RO(current
, node
, gstack
))
376 if (!exact_match_exists
)
378 (match_token(gstack
[0]->data
,
384 for (ALL_LIST_ELEMENTS_RO(current
, node
, gstack
)) {
385 struct cmd_token
*token
= gstack
[0]->data
;
387 if (token
->attr
== CMD_ATTR_HIDDEN
388 || token
->attr
== CMD_ATTR_DEPRECATED
)
391 enum match_type minmatch
= min_match_level(token
->type
);
392 trace_matcher("\"%s\" matches \"%s\" (%d) ? ",
393 input_token
, token
->text
, token
->type
);
395 unsigned int last_token
=
396 (vector_active(vline
) - 1 == idx
);
397 enum match_type matchtype
=
398 match_token(token
, input_token
);
400 // occurs when last token is whitespace
402 trace_matcher("trivial_match\n");
404 newstack
= XMALLOC(MTYPE_CMD_MATCHSTACK
,
405 sizeof(struct graph_node
*));
406 /* we're not recursing here, just the first
408 newstack
[0] = gstack
[0];
409 listnode_add(next
, newstack
);
412 trace_matcher("trivial_match\n");
413 if (exact_match_exists
&& !last_token
)
417 trace_matcher("exact_match\n");
420 MTYPE_CMD_MATCHSTACK
,
421 sizeof(struct graph_node
*));
422 /* same as above, not recursing on this
424 newstack
[0] = gstack
[0];
425 listnode_add(next
, newstack
);
426 } else if (matchtype
>= minmatch
)
427 add_nexthops(next
, gstack
[0], gstack
,
431 trace_matcher("no_match\n");
438 * -----------------------------------------------------------------
439 * token = last input token processed
440 * idx = index in `command` of last token processed
441 * current = set of all transitions from the previous input token
442 * next = set of all nodes reachable from all nodes in `matched`
445 enum matcher_rv mrv
= idx
== vector_active(vline
) && next
->count
450 if (!MATCHER_ERROR(mrv
)) {
451 // extract cmd_token into list
452 *completions
= list_new();
453 for (ALL_LIST_ELEMENTS_RO(next
, node
, gstack
)) {
454 listnode_add(*completions
, gstack
[0]->data
);
458 list_delete_and_null(¤t
);
459 list_delete_and_null(&next
);
465 * Adds all children that are reachable by one parser hop to the given list.
466 * special tokens except END_TKN are treated as transparent.
468 * @param[in] list to add the nexthops to
469 * @param[in] node to start calculating nexthops from
470 * @param[in] stack listing previously visited nodes, if non-NULL.
471 * @param[in] stackpos how many valid entries are in stack
472 * @return the number of children added to the list
474 * NB: non-null "stack" means that new stacks will be added to "list" as
475 * output, instead of direct node pointers!
477 static int add_nexthops(struct list
*list
, struct graph_node
*node
,
478 struct graph_node
**stack
, size_t stackpos
)
481 struct graph_node
*child
;
482 struct graph_node
**nextstack
;
483 for (unsigned int i
= 0; i
< vector_active(node
->to
); i
++) {
484 child
= vector_slot(node
->to
, i
);
486 struct cmd_token
*token
= child
->data
;
487 if (!token
->allowrepeat
&& stack
) {
488 for (j
= 0; j
< stackpos
; j
++)
489 if (child
== stack
[j
])
494 if (token
->type
>= SPECIAL_TKN
&& token
->type
!= END_TKN
) {
495 added
+= add_nexthops(list
, child
, stack
, stackpos
);
499 MTYPE_CMD_MATCHSTACK
,
501 * sizeof(struct graph_node
*));
502 nextstack
[0] = child
;
503 memcpy(nextstack
+ 1, stack
,
504 stackpos
* sizeof(struct graph_node
*));
506 listnode_add(list
, nextstack
);
508 listnode_add(list
, child
);
517 * Determines the node types for which a partial match may count as a full
518 * match. Enables command abbrevations.
520 * @param[in] type node type
521 * @return minimum match level needed to for a token to fully match
523 static enum match_type
min_match_level(enum cmd_token_type type
)
526 // anything matches a start node, for the sake of recursion
529 // allowing words to partly match enables command abbreviation
538 * Assigns precedence scores to node types.
540 * @param[in] type node type to score
541 * @return precedence score
543 static int score_precedence(enum cmd_token_type type
)
546 // some of these are mutually exclusive, so they share
547 // the same precedence value
549 case IPV4_PREFIX_TKN
:
551 case IPV6_PREFIX_TKN
:
566 * Picks the better of two possible matches for a token.
568 * @param[in] first candidate node matching token
569 * @param[in] second candidate node matching token
570 * @param[in] token the token being matched
571 * @return the best-matching node, or NULL if the two are entirely ambiguous
573 static struct cmd_token
*disambiguate_tokens(struct cmd_token
*first
,
574 struct cmd_token
*second
,
577 // if the types are different, simply go off of type precedence
578 if (first
->type
!= second
->type
) {
579 int firstprec
= score_precedence(first
->type
);
580 int secndprec
= score_precedence(second
->type
);
581 if (firstprec
!= secndprec
)
582 return firstprec
< secndprec
? first
: second
;
587 // if they're the same, return the more exact match
588 enum match_type fmtype
= match_token(first
, input_token
);
589 enum match_type smtype
= match_token(second
, input_token
);
590 if (fmtype
!= smtype
)
591 return fmtype
> smtype
? first
: second
;
597 * Picks the better of two possible matches for an input line.
599 * @param[in] first candidate list of cmd_token matching vline
600 * @param[in] second candidate list of cmd_token matching vline
601 * @param[in] vline the input line being matched
602 * @param[in] n index into vline to start comparing at
603 * @return the best-matching list, or NULL if the two are entirely ambiguous
605 static struct list
*disambiguate(struct list
*first
, struct list
*second
,
606 vector vline
, unsigned int n
)
608 // doesn't make sense for these to be inequal length
609 assert(first
->count
== second
->count
);
610 assert(first
->count
== vector_active(vline
) - n
+ 1);
612 struct listnode
*fnode
= listhead(first
), *snode
= listhead(second
);
613 struct cmd_token
*ftok
= listgetdata(fnode
), *stok
= listgetdata(snode
),
616 // compare each token, if one matches better use that one
617 for (unsigned int i
= n
; i
< vector_active(vline
); i
++) {
618 char *token
= vector_slot(vline
, i
);
619 if ((best
= disambiguate_tokens(ftok
, stok
, token
)))
620 return best
== ftok
? first
: second
;
621 fnode
= listnextnode(fnode
);
622 snode
= listnextnode(snode
);
623 ftok
= listgetdata(fnode
);
624 stok
= listgetdata(snode
);
631 * Deletion function for arglist.
633 * Since list->del for arglists expects all listnode->data to hold cmd_token,
634 * but arglists have cmd_element as the data for the tail, this function
635 * manually deletes the tail before deleting the rest of the list as usual.
637 * The cmd_element at the end is *not* a copy. It is the one and only.
639 * @param list the arglist to delete
641 static void del_arglist(struct list
*list
)
643 // manually delete last node
644 struct listnode
*tail
= listtail(list
);
646 list_delete_node(list
, tail
);
648 // delete the rest of the list as usual
649 list_delete_and_null(&list
);
652 /*---------- token level matching functions ----------*/
654 static enum match_type
match_token(struct cmd_token
*token
, char *input_token
)
656 // nothing trivially matches everything
658 return trivial_match
;
660 switch (token
->type
) {
662 return match_word(token
, input_token
);
664 return match_ipv4(input_token
);
665 case IPV4_PREFIX_TKN
:
666 return match_ipv4_prefix(input_token
);
668 return match_ipv6_prefix(input_token
, false);
669 case IPV6_PREFIX_TKN
:
670 return match_ipv6_prefix(input_token
, true);
672 return match_range(token
, input_token
);
674 return match_variable(token
, input_token
);
676 return match_mac(input_token
, false);
678 return match_mac(input_token
, true);
685 #define IPV4_ADDR_STR "0123456789."
686 #define IPV4_PREFIX_STR "0123456789./"
688 static enum match_type
match_ipv4(const char *str
)
691 int dots
= 0, nums
= 0;
695 memset(buf
, 0, sizeof(buf
));
697 while (*str
!= '\0') {
702 if (*(str
+ 1) == '.')
705 if (*(str
+ 1) == '\0')
711 if (!isdigit((int)*str
))
720 strncpy(buf
, sp
, str
- sp
);
738 static enum match_type
match_ipv4_prefix(const char *str
)
745 memset(buf
, 0, sizeof(buf
));
747 while (*str
!= '\0' && *str
!= '/') {
752 if (*(str
+ 1) == '.' || *(str
+ 1) == '/')
755 if (*(str
+ 1) == '\0')
762 if (!isdigit((int)*str
))
771 strncpy(buf
, sp
, str
- sp
);
777 if (*(str
+ 1) == '\0')
782 } else if (*str
== '\0')
793 while (*str
!= '\0') {
794 if (!isdigit((int)*str
))
807 #define IPV6_ADDR_STR "0123456789abcdefABCDEF:."
808 #define IPV6_PREFIX_STR "0123456789abcdefABCDEF:./"
809 #define STATE_START 1
810 #define STATE_COLON 2
811 #define STATE_DOUBLE 3
814 #define STATE_SLASH 6
817 static enum match_type
match_ipv6_prefix(const char *str
, bool prefix
)
819 int state
= STATE_START
;
820 int colons
= 0, nums
= 0, double_colon
= 0;
822 const char *sp
= NULL
, *start
= str
;
828 if (strspn(str
, prefix
? IPV6_PREFIX_STR
: IPV6_ADDR_STR
)
832 while (*str
!= '\0' && state
!= STATE_MASK
) {
836 if (*(str
+ 1) != ':' && *(str
+ 1) != '\0')
848 if (*(str
+ 1) == '/')
850 else if (*(str
+ 1) == ':')
851 state
= STATE_DOUBLE
;
861 if (*(str
+ 1) == ':')
864 if (*(str
+ 1) != '\0' && *(str
+ 1) != '/')
868 if (*(str
+ 1) == '/')
878 if (*(str
+ 1) == ':' || *(str
+ 1) == '.'
879 || *(str
+ 1) == '\0' || *(str
+ 1) == '/') {
883 for (; sp
<= str
; sp
++)
889 if (*(str
+ 1) == ':')
891 else if (*(str
+ 1) == '.') {
892 if (colons
|| double_colon
)
896 } else if (*(str
+ 1) == '/')
904 if (*(str
+ 1) == '\0')
923 struct sockaddr_in6 sin6_dummy
;
924 int ret
= inet_pton(AF_INET6
, start
, &sin6_dummy
.sin6_addr
);
925 return ret
== 1 ? exact_match
: partly_match
;
928 if (state
< STATE_MASK
)
931 mask
= strtol(str
, &endptr
, 10);
935 if (mask
< 0 || mask
> 128)
941 static enum match_type
match_range(struct cmd_token
*token
, const char *str
)
943 assert(token
->type
== RANGE_TKN
);
948 val
= strtoll(str
, &endptr
, 10);
952 if (val
< token
->min
|| val
> token
->max
)
958 static enum match_type
match_word(struct cmd_token
*token
, const char *word
)
960 assert(token
->type
== WORD_TKN
);
962 // if the passed token is 0 length, partly match
966 // if the passed token is strictly a prefix of the full word, partly
968 if (strlen(word
) < strlen(token
->text
))
969 return !strncmp(token
->text
, word
, strlen(word
)) ? partly_match
972 // if they are the same length and exactly equal, exact match
973 else if (strlen(word
) == strlen(token
->text
))
974 return !strncmp(token
->text
, word
, strlen(word
)) ? exact_match
980 static enum match_type
match_variable(struct cmd_token
*token
, const char *word
)
982 assert(token
->type
== VARIABLE_TKN
);
986 #define MAC_CHARS "ABCDEFabcdef0123456789:"
988 static enum match_type
match_mac(const char *word
, bool prefix
)
990 /* 6 2-digit hex numbers separated by 5 colons */
991 size_t mac_explen
= 6 * 2 + 5;
992 /* '/' + 2-digit integer */
993 size_t mask_len
= 1 + 2;
996 unsigned int maskval
;
999 if (strlen(word
) > mac_explen
+ (prefix
? mask_len
: 0))
1003 for (i
= 0; i
< mac_explen
; i
++) {
1004 if (word
[i
] == '\0' || !strchr(MAC_CHARS
, word
[i
]))
1006 if (((i
+ 1) % 3 == 0) != (word
[i
] == ':'))
1010 /* incomplete address */
1011 if (i
< mac_explen
&& word
[i
] == '\0')
1012 return partly_match
;
1013 else if (i
< mac_explen
)
1017 if (prefix
&& word
[i
] == '/') {
1018 if (word
[++i
] == '\0')
1019 return partly_match
;
1021 maskval
= strtoul(&word
[i
], &eptr
, 10);
1022 if (*eptr
!= '\0' || maskval
> 48)
1024 } else if (prefix
&& word
[i
] == '\0') {
1025 return partly_match
;
1026 } else if (prefix
) {