Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
8fdc37ab
Commit
8fdc37ab
authored
Jan 13, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Don't show option candidates if full-match or single prefix-match
parent
a54c5bef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
src/util.cc
src/util.cc
+18
-6
No files found.
src/util.cc
View file @
8fdc37ab
...
...
@@ -324,14 +324,26 @@ void show_candidates(const char *unkopt, option *options)
if
(
*
unkopt
==
'\0'
)
{
return
;
}
int
prefix_match
=
0
;
auto
unkoptlen
=
strlen
(
unkopt
);
auto
cands
=
std
::
vector
<
std
::
pair
<
int
,
const
char
*>>
();
for
(
size_t
i
=
0
;
options
[
i
].
name
!=
nullptr
;
++
i
)
{
// Use cost 0 for prefix or suffix match
if
(
istartsWith
(
options
[
i
].
name
,
unkopt
)
||
(
unkoptlen
>=
3
&&
iendsWith
(
options
[
i
].
name
,
options
[
i
].
name
+
strlen
(
options
[
i
].
name
),
unkopt
,
unkopt
+
unkoptlen
)))
{
auto
optnamelen
=
strlen
(
options
[
i
].
name
);
// Use cost 0 for prefix match
if
(
istartsWith
(
options
[
i
].
name
,
options
[
i
].
name
+
optnamelen
,
unkopt
,
unkopt
+
unkoptlen
))
{
if
(
optnamelen
==
unkoptlen
)
{
// Exact match, then we don't show any condidates.
return
;
}
++
prefix_match
;
cands
.
emplace_back
(
0
,
options
[
i
].
name
);
continue
;
}
// Use cost 0 for suffix match, but match at least 3 characters
if
(
unkoptlen
>=
3
&&
iendsWith
(
options
[
i
].
name
,
options
[
i
].
name
+
optnamelen
,
unkopt
,
unkopt
+
unkoptlen
))
{
cands
.
emplace_back
(
0
,
options
[
i
].
name
);
continue
;
}
...
...
@@ -339,7 +351,7 @@ void show_candidates(const char *unkopt, option *options)
int
sim
=
levenshtein
(
unkopt
,
options
[
i
].
name
,
0
,
2
,
1
,
3
);
cands
.
emplace_back
(
sim
,
options
[
i
].
name
);
}
if
(
cands
.
empty
())
{
if
(
prefix_match
==
1
||
cands
.
empty
())
{
return
;
}
std
::
sort
(
std
::
begin
(
cands
),
std
::
end
(
cands
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment