mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-21 10:19:04 +00:00
sh: improve style
This commit is contained in:
parent
411942a70e
commit
43489c142e
|
@ -589,15 +589,16 @@ static int
|
|||
comparator(const void *a, const void *b, void *thunk)
|
||||
{
|
||||
size_t curpos = (intptr_t)thunk;
|
||||
|
||||
return (strcmp(*(char *const *)a + curpos,
|
||||
*(char *const *)b + curpos));
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is passed to libedit's fn_complete2(). The library will
|
||||
* use it instead of its standard function that finds matching files in
|
||||
* current directory. If we're at the start of the line, we want to look
|
||||
* for available commands from all paths in $PATH.
|
||||
* This function is passed to libedit's fn_complete2(). The library will use
|
||||
* it instead of its standard function that finds matching files in current
|
||||
* directory. If we're at the start of the line, we want to look for
|
||||
* available commands from all paths in $PATH.
|
||||
*/
|
||||
static char
|
||||
**sh_matches(const char *text, int start, int end)
|
||||
|
@ -681,13 +682,13 @@ static char
|
|||
}
|
||||
matches[uniq + 1] = NULL;
|
||||
/*
|
||||
* matches[0] is special: it's not a real matching file name but a common
|
||||
* prefix for all matching names. It can't be null, unlike any other
|
||||
* element of the array. When strings matches[0] and matches[1] compare
|
||||
* equal and matches[2] is null that means to libedit that there is only
|
||||
* a single match. It will then replace user input with possibly escaped
|
||||
* string in matches[0] which is the reason to copy the full name of the
|
||||
* only match.
|
||||
* matches[0] is special: it's not a real matching file name but
|
||||
* a common prefix for all matching names. It can't be null, unlike
|
||||
* any other element of the array. When strings matches[0] and
|
||||
* matches[1] compare equal and matches[2] is null that means to
|
||||
* libedit that there is only a single match. It will then replace
|
||||
* user input with possibly escaped string in matches[0] which is the
|
||||
* reason to copy the full name of the only match.
|
||||
*/
|
||||
if (uniq == 1)
|
||||
matches[0] = strdup(matches[1]);
|
||||
|
|
Loading…
Reference in a new issue