49893: Fix comments for UNIQCON/ALL

This commit is contained in:
Mikael Magnusson 2022-03-25 23:57:30 +01:00
parent 596b8e3fae
commit 48be30e530
3 changed files with 15 additions and 4 deletions

View File

@ -5,6 +5,11 @@
* 49908: Test/ztst.zsh: reset LC_CTYPE to C during tests.
2022-03-30 Mikael Magnusson <mikachu@gmail.com>
* 49893: Src/Zle/comp.h, Src/Zle/compcore.c: Fix comments for
UNIQCON/ALL
2022-03-29 Bart Schaefer <schaefer@zsh.org>
* 49918: NEWS, README: Update for 49917 and 49911.

View File

@ -85,8 +85,8 @@ struct cmgroup {
#define CGF_NOSORT 1 /* don't sort this group */
#define CGF_LINES 2 /* these are to be printed on different lines */
#define CGF_HASDL 4 /* has display strings printed on separate lines */
#define CGF_UNIQALL 8 /* remove all duplicates */
#define CGF_UNIQCON 16 /* remove consecutive duplicates */
#define CGF_UNIQALL 8 /* remove consecutive duplicates (if neither are set, */
#define CGF_UNIQCON 16 /* don't deduplicate */ /* remove all dupes) */
#define CGF_PACKED 32 /* LIST_PACKED for this group */
#define CGF_ROWS 64 /* LIST_ROWS_FIRST for this group */
#define CGF_FILES 128 /* contains file names */
@ -299,7 +299,7 @@ struct menuinfo {
#define CAF_NOSORT 2 /* compadd -V: don't sort */
#define CAF_MATCH 4 /* compadd without -U: do matching */
#define CAF_UNIQCON 8 /* compadd -2: don't deduplicate */
#define CAF_UNIQALL 16 /* compadd -1: deduplicate */
#define CAF_UNIQALL 16 /* compadd -1: deduplicate consecutive only */
#define CAF_ARRAYS 32 /* compadd -a or -k: array/assoc parameter names */
#define CAF_KEYS 64 /* compadd -k: assoc parameter names */
#define CAF_ALL 128 /* compadd -C: _all_matches */

View File

@ -3254,10 +3254,13 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
qsort((void *) rp, n, sizeof(Cmatch),
(int (*) _((const void *, const void *)))matchcmp);
/* since the matches are sorted and the default is to remove
* all duplicates, -1 (remove only consecutive dupes) is a no-op,
* so this condition only checks for -2 */
if (!(flags & CGF_UNIQCON)) {
int dup;
/* And delete the ones that occur more than once. */
/* we did not pass -2 so go ahead and remove those dupes */
for (ap = cp = rp; *ap; ap++) {
*cp++ = *ap;
for (bp = ap; bp[1] && matcheq(*ap, bp[1]); bp++, n--);
@ -3279,7 +3282,9 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
if ((*ap)->flags & (CMF_NOLIST | CMF_MULT))
nl++;
}
/* used -O nosort or -V, don't sort */
} else {
/* didn't use -1 or -2, so remove all duplicates (inefficient) */
if (!(flags & CGF_UNIQALL) && !(flags & CGF_UNIQCON)) {
int dup;
@ -3303,6 +3308,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
(*ap)->flags |= CMF_FMULT;
}
}
/* passed -1 but not -2, so remove consecutive duplicates (efficient) */
} else if (!(flags & CGF_UNIQCON)) {
int dup;