]> Sergey Matveev's repositories - nnn.git/commitdiff
Use case insensitive version sort to compare
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 16 Jun 2019 13:26:11 +0000 (18:56 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 17 Jun 2019 01:34:25 +0000 (07:04 +0530)
README.md
nnn.1
scripts/auto-completion/bash/nnn-completion.bash
scripts/auto-completion/fish/nnn.fish
scripts/auto-completion/zsh/_nnn
src/nnn.c

index 4c603a097f930555230538fa63f262ee4e3fea54..44e37de983599622d284baf5f9f2a4ad1ae4cac9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/nnn.1 b/nnn.1
index 9f6285863b9ddeee1e085ffefc54b34303b639fb..be88adb83b4fc16e5a81e4521d5c98e97191bad3 100644 (file)
--- a/nnn.1
+++ b/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
index 25bbed08cbd0b359be5bf522549f9a053bed6c29..4c81e770ca6858c8c449e4828a528bcbab31d74c 100644 (file)
@@ -17,7 +17,6 @@ _nnn () {
         -h
         -i
         -l
-        -n
         -p
         -s
         -S
index 02f80246dedf0f1922e1b8aadde8e63023acd733..c0a6b1f02d4710c2fe57182f153fab010e2b5563 100644 (file)
@@ -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'
index 20a313fc209c8e221ea17d0d1ec8cc9e0680d358..17d1c1a3c654f84be653764582fc549338f0cd4a 100644 (file)
@@ -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]'
index cc6541cd455c69d0fba36c802c6e48a769e18cc9..d9db166ac381c5f49837f9a8afd030387a08dd79 100644 (file)
--- a/src/nnn.c
+++ b/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')