* [PATCH] check length before call strncmp in range_type()
@ 2015-06-18 2:37 Han Pingtian
0 siblings, 0 replies; only message in thread
From: Han Pingtian @ 2015-06-18 2:37 UTC (permalink / raw)
To: zsh-workers
When called by 'compadd -M 'M:[[:a:]]=[[:b:]] ....', range_type() will
return PP_ALPHA for [:a:] and PP_BLANK for [:b:]. Checking if len equals
the length of items of colon_stuffs first may fix this problem.
---
Src/pattern.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Src/pattern.c b/Src/pattern.c
index 7e07548..8fa1a72 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1113,8 +1113,8 @@ range_type(char *start, int len)
const char **csp;
for (csp = colon_stuffs; *csp; csp++) {
- if (!strncmp(start, *csp, len))
- return (csp - colon_stuffs) + PP_FIRST;
+ if (strlen(*csp) == len && !strncmp(start, *csp, len))
+ return (csp - colon_stuffs) + PP_FIRST;
}
return PP_UNKWN;
--
1.9.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-06-18 2:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-18 2:37 [PATCH] check length before call strncmp in range_type() Han Pingtian
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).