git: 43489c142e56 - main - sh: improve style
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 13 May 2023 20:06:04 UTC
The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=43489c142e5686ef92b632afa847f4aa4ce8a526 commit 43489c142e5686ef92b632afa847f4aa4ce8a526 Author: Piotr Pawel Stefaniak <pstef@FreeBSD.org> AuthorDate: 2023-04-29 20:42:15 +0000 Commit: Piotr Pawel Stefaniak <pstef@FreeBSD.org> CommitDate: 2023-05-13 19:57:27 +0000 sh: improve style --- bin/sh/histedit.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index db3b8bcfc1da..07a344ebd17b 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -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 @@ out: } 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]);