mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 03:41:27 +00:00
Use case insensitive version sort to compare
This commit is contained in:
parent
815155033d
commit
32b3445f3b
|
@ -78,9 +78,8 @@ It runs on Linux, macOS, Raspberry Pi, BSD, Cygwin, Linux subsystem for Windows
|
|||
- Bookmarks; pin and visit a directory
|
||||
- Familiar, easy shortcuts (arrows, <kbd>~</kbd>, <kbd>-</kbd>, <kbd>@</kbd>)
|
||||
- Sorting
|
||||
- Ordered pure numeric names by default (visit _/proc_)
|
||||
- Case-insensitive version (_aka_ natural) sort
|
||||
- Sort by file name, modification time, size
|
||||
- Version (_aka_ natural) sort
|
||||
- Search
|
||||
- Instant filtering with *search-as-you-type*
|
||||
- Regex and substring match
|
||||
|
@ -199,8 +198,8 @@ Option completion scripts for Bash, Fish and Zsh can be found in respective subd
|
|||
#### Cmdline options
|
||||
|
||||
```
|
||||
usage: nnn [-b key] [-d] [-e] [-i] [-l] [-n]
|
||||
[-p file] [-s] [-S] [-v] [-w] [-h] [PATH]
|
||||
usage: nnn [-b key] [-d] [-e] [-i] [-l] [-p file]
|
||||
[-s] [-S] [-v] [-w] [-h] [PATH]
|
||||
|
||||
The missing terminal file manager for X.
|
||||
|
||||
|
@ -213,7 +212,6 @@ optional args:
|
|||
-e use exiftool for media info
|
||||
-i nav-as-you-type mode
|
||||
-l light mode
|
||||
-n use version compare to sort
|
||||
-p file selection file (stdout if '-')
|
||||
-s string filters [default: regex]
|
||||
-S du mode
|
||||
|
|
4
nnn.1
4
nnn.1
|
@ -11,7 +11,6 @@
|
|||
.Op Ar -e
|
||||
.Op Ar -i
|
||||
.Op Ar -l
|
||||
.Op Ar -n
|
||||
.Op Ar -p file
|
||||
.Op Ar -s
|
||||
.Op Ar -S
|
||||
|
@ -52,9 +51,6 @@ supports the following options:
|
|||
.Fl l
|
||||
start in light mode (fewer details)
|
||||
.Pp
|
||||
.Fl n
|
||||
use version compare to sort files
|
||||
.Pp
|
||||
.Fl "p file"
|
||||
copy (or \fIpick\fR) selection to file, or stdout if file='-'
|
||||
.Pp
|
||||
|
|
|
@ -17,7 +17,6 @@ _nnn () {
|
|||
-h
|
||||
-i
|
||||
-l
|
||||
-n
|
||||
-p
|
||||
-s
|
||||
-S
|
||||
|
|
|
@ -11,7 +11,6 @@ complete -c nnn -s e -d 'use exiftool instead of mediainfo'
|
|||
complete -c nnn -s h -d 'show this help and exit'
|
||||
complete -c nnn -s i -d 'start in navigate-as-you-type mode'
|
||||
complete -c nnn -s l -d 'start in light mode (fewer details)'
|
||||
complete -c nnn -s n -d 'use version compare to sort files'
|
||||
complete -c nnn -s p -r -d 'copy selection to file'
|
||||
complete -c nnn -s s -d 'use substring match for filters'
|
||||
complete -c nnn -s S -d 'start in disk usage analyzer mode'
|
||||
|
|
|
@ -15,7 +15,6 @@ args=(
|
|||
'(-h)-h[show this help and exit]'
|
||||
'(-i)-i[start in navigate-as-you-type mode]'
|
||||
'(-l)-l[start in light mode (fewer details)]'
|
||||
'(-n)-n[use version compare to sort files]'
|
||||
'(-p)-p[copy selection to file]:file name'
|
||||
'(-s)-s[use substring match for filters]'
|
||||
'(-S)-S[start in disk usage analyzer mode]'
|
||||
|
|
20
src/nnn.c
20
src/nnn.c
|
@ -1246,6 +1246,7 @@ static bool write_lastdir(const char *curpath)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int digit_compare(const char *a, const char *b)
|
||||
{
|
||||
while (*a && *b && *a == *b)
|
||||
|
@ -1333,6 +1334,7 @@ static int xstricmp(const char * const s1, const char * const s2)
|
|||
|
||||
return strcoll(s1, s2);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Version comparison
|
||||
|
@ -1346,8 +1348,10 @@ static int xstricmp(const char * const s1, const char * const s2)
|
|||
* Compare S1 and S2 as strings holding indices/version numbers,
|
||||
* returning less than, equal to or greater than zero if S1 is less than,
|
||||
* equal to or greater than S2 (for more info, see the texinfo doc).
|
||||
*
|
||||
* Ignores case.
|
||||
*/
|
||||
static int xstrverscmp(const char * const s1, const char * const s2)
|
||||
static int xstrverscasecmp(const char * const s1, const char * const s2)
|
||||
{
|
||||
const uchar *p1 = (const uchar *)s1;
|
||||
const uchar *p2 = (const uchar *)s2;
|
||||
|
@ -1413,8 +1417,6 @@ static int xstrverscmp(const char * const s1, const char * const s2)
|
|||
}
|
||||
}
|
||||
|
||||
static int (*cmpfn)(const char * const s1, const char * const s2) = &xstricmp;
|
||||
|
||||
/* Return the integer value of a char representing HEX */
|
||||
static char xchartohex(char c)
|
||||
{
|
||||
|
@ -1484,7 +1486,7 @@ static int entrycmp(const void *va, const void *vb)
|
|||
return -1;
|
||||
}
|
||||
|
||||
return cmpfn(pa->name, pb->name);
|
||||
return xstrverscasecmp(pa->name, pb->name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4289,8 +4291,8 @@ nochange:
|
|||
static void usage(void)
|
||||
{
|
||||
fprintf(stdout,
|
||||
"%s: nnn [-b key] [-d] [-e] [-i] [-l] [-n]\n"
|
||||
" [-p file] [-s] [-S] [-v] [-w] [-h] [PATH]\n\n"
|
||||
"%s: nnn [-b key] [-d] [-e] [-i] [-l] [-p file]\n"
|
||||
" [-s] [-S] [-v] [-w] [-h] [PATH]\n\n"
|
||||
"The missing terminal file manager for X.\n\n"
|
||||
"positional args:\n"
|
||||
" PATH start dir [default: current dir]\n\n"
|
||||
|
@ -4300,7 +4302,6 @@ static void usage(void)
|
|||
" -e use exiftool for media info\n"
|
||||
" -i nav-as-you-type mode\n"
|
||||
" -l light mode\n"
|
||||
" -n use version compare to sort\n"
|
||||
" -p file selection file (stdout if '-')\n"
|
||||
" -s string filters [default: regex]\n"
|
||||
" -S du mode\n"
|
||||
|
@ -4434,7 +4435,7 @@ int main(int argc, char *argv[])
|
|||
char *arg = NULL;
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "Slib:denp:svwh")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "Slib:dep:svwh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'S':
|
||||
cfg.blkorder = 1;
|
||||
|
@ -4457,9 +4458,6 @@ int main(int argc, char *argv[])
|
|||
case 'e':
|
||||
cfg.metaviewer = EXIFTOOL;
|
||||
break;
|
||||
case 'n':
|
||||
cmpfn = &xstrverscmp;
|
||||
break;
|
||||
case 'p':
|
||||
cfg.picker = 1;
|
||||
if (optarg[0] == '-' && optarg[1] == '\0')
|
||||
|
|
Loading…
Reference in a new issue