Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Remove special case sort from completion
- X-seq: zsh-workers 41242
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Remove special case sort from completion
- Date: Wed, 7 Jun 2017 00:25:34 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:to:subject:mime-version; bh=nOHfFpM6N9O26BQKWMInT1zwPi6pKzd+8c8whS1AZOE=; b=OiAbbH2l51ZHH6NGHCvobp10quEt/zgRwzpwFoBEEEDwt/UB3Jbhyw/cZJ8wTJo0Lg CW6AOEN/rZIN0zB8Oq2cC4PHJ0BFnjlFgvpF3unqgFZ1Gu7B9UiHVdpJGGqHoaOadJ35 0FqNDcXK985we8w5aQk5ZTjvM2zfIJrfjNOQ5/U/AWG6jdcTa4v7K52syGGS63Z4+1U1 Q9dkbUifMCpkqzBsh7SM8msJKlekWJJ2S050O/z9qMpWZgZue3/c+PRFDFAWtIOR+STh IBFkJej/HMq1o2ekp9kFlS3vom0R/aTqK6vMZ4nZcWp+gRgX1op0HtIWlFtuvf+1Pc3n 5R9Q==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
In the context of the discussion about numericglobsort, there appears to
be some redundant and possibly inconsistently-implemented code used for
sorting completion results.
Other than that it may be somewhat slower, does anyone see a problem with
the following?
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index d1cf7a0..52b0c17 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -3135,7 +3135,9 @@ matchcmp(Cmatch *a, Cmatch *b)
if ((*b)->disp && !((*b)->flags & CMF_MORDER))
return 1;
- return zstrbcmp((*a)->str, (*b)->str);
+ return zstrcmp((*a)->str, (*b)->str, (SORTIT_IGNORING_BACKSLASHES|
+ (isset(NUMERICGLOBSORT) ?
+ SORTIT_NUMERICALLY : 0)));
}
/* This tests whether two matches are equal (would produce the same
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 3d86791..5a9cccb 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2407,53 +2407,6 @@ sfxlen(char *s, char *t)
}
#endif
-/* This is zstrcmp with ignoring backslashes. */
-
-/**/
-mod_export int
-zstrbcmp(const char *a, const char *b)
-{
- const char *astart = a;
-
- while (*a && *b) {
- if (*a == '\\')
- a++;
- if (*b == '\\')
- b++;
- if (*a != *b || !*a)
- break;
- a++;
- b++;
- }
- if (isset(NUMERICGLOBSORT) && (idigit(*a) || idigit(*b))) {
- for (; a > astart && idigit(a[-1]); a--, b--);
- if (idigit(*a) && idigit(*b)) {
- while (*a == '0')
- a++;
- while (*b == '0')
- b++;
- for (; idigit(*a) && *a == *b; a++, b++);
- if (idigit(*a) || idigit(*b)) {
- int cmp = (int) STOUC(*a) - (int) STOUC(*b);
-
- while (idigit(*a) && idigit(*b))
- a++, b++;
- if (idigit(*a) && !idigit(*b))
- return 1;
- if (idigit(*b) && !idigit(*a))
- return -1;
-
- return cmp;
- }
- }
- }
-#ifndef HAVE_STRCOLL
- return (int)(*a - *b);
-#else
- return strcoll(a,b);
-#endif
-}
-
/* This is used to print the strings (e.g. explanations). *
* It returns the number of lines printed. */
Messages sorted by:
Reverse Date,
Date,
Thread,
Author