Hello, ls and sort is modified by this patch to use new gnulib function filevercmp instead of strverscmp from glibc. It requires gnulib-filevercmp.patch to be applied on gnulib since this patch has not been pushed to git yet. More information and the patch for gnulib can be found in the thread: http://lists.gnu.org/archive/html/bug-gnulib/2008-09/msg00365.html
Kamil
From 6464e9931bf7d9b480ef2dda15831a0c81530b6e Mon Sep 17 00:00:00 2001 From: Kamil Dudka <[EMAIL PROTECTED]> Date: Mon, 29 Sep 2008 15:41:43 +0200 Subject: [PATCH] ls and sort: use filevercmp instead of strverscmp * src/ls.c (cmp_version): Use filevercmp instead of strverscmp. * src/sort.c (usage): Remove mna reference to strverscmp(3). (compare_version): Use filevercmp instead of strverscmp. * bootstrap.conf: Add filevercmp to list of gnulib modules. * NEWS: Mention the change. --- NEWS | 4 +++- bootstrap.conf | 2 +- src/ls.c | 8 +++++--- src/sort.c | 9 +++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index b3eb3a9..c32079b 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,8 @@ GNU coreutils NEWS -*- outline -*- ls now colorizes files with capabilities if libcap is available + ls -v now uses filevercmp function as sort predicate (instead of strverscmp) + md5sum now accepts the new option, --quiet, to suppress the printing of 'OK' messages. sha1sum, sha224sum, sha384sum, and sha512sum accept it, too. @@ -53,7 +55,7 @@ GNU coreutils NEWS -*- outline -*- When processing more than NMERGE inputs, sort uses temporary files. sort accepts a new option --version-sort (-V, --sort=version), - specifying that ordering is to be based on strverscmp(3). + specifying that ordering is to be based on filevercmp. ** Bug fixes diff --git a/bootstrap.conf b/bootstrap.conf index 5685ad5..b3eec48 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -48,7 +48,7 @@ gnulib_modules=" cycle-check d-ino d-type diacrit dirfd dirname dup2 error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl - file-type fileblocks filemode filenamecat fnmatch-gnu + file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime fseeko diff --git a/src/ls.c b/src/ls.c index aeece67..e107162 100644 --- a/src/ls.c +++ b/src/ls.c @@ -94,6 +94,7 @@ #include "hash.h" #include "human.h" #include "filemode.h" +#include "filevercmp.h" #include "idcache.h" #include "ls.h" #include "lstat.h" @@ -3123,8 +3124,9 @@ DEFINE_SORT_FUNCTIONS (extension, cmp_extension) /* Compare file versions. Unlike all other compare functions above, cmp_version depends only - on strverscmp, which does not fail (even for locale reasons), and does not - need a secondary sort key. + on filevercmp, which does not fail (even for locale reasons), and does not + need a secondary sort key. See lib/filevercmp.h for function description. + All the other sort options, in fact, need xstrcoll and strcmp variants, because they all use a string comparison (either as the primary or secondary sort key), and xstrcoll has the ability to do a longjmp if strcoll fails for @@ -3133,7 +3135,7 @@ DEFINE_SORT_FUNCTIONS (extension, cmp_extension) static inline int cmp_version (struct fileinfo const *a, struct fileinfo const *b) { - return strverscmp (a->name, b->name); + return filevercmp (a->name, b->name); } static int xstrcoll_version (V a, V b) diff --git a/src/sort.c b/src/sort.c index 44bfbe0..43c28fc 100644 --- a/src/sort.c +++ b/src/sort.c @@ -29,6 +29,7 @@ #include "system.h" #include "argmatch.h" #include "error.h" +#include "filevercmp.h" #include "hard-locale.h" #include "hash.h" #include "md5.h" @@ -346,7 +347,7 @@ Ordering options:\n\ --sort=WORD sort according to WORD:\n\ general-numeric -g, month -M, numeric -n,\n\ random -R, version -V\n\ - -V, --version-sort sort by numeric version (see strverscmp(3))\n\ + -V, --version-sort sort by numeric version\n\ \n\ "), stdout); fputs (_("\ @@ -1823,7 +1824,7 @@ compare_random (char *restrict texta, size_t lena, } /* Compare the keys TEXTA (of length LENA) and TEXTB (of length LENB) - using strverscmp. */ + using filevercmp. See lib/filevercmp.h for function description. */ static int compare_version (char *restrict texta, size_t lena, @@ -1832,7 +1833,7 @@ compare_version (char *restrict texta, size_t lena, int diff; /* It is necessary to save the character after the end of the field. - "strverscmp" works with NUL terminated strings. Our blocks of + "filevercmp" works with NUL terminated strings. Our blocks of text are not necessarily terminated with a NUL byte. */ char sv_a = texta[lena]; char sv_b = textb[lenb]; @@ -1840,7 +1841,7 @@ compare_version (char *restrict texta, size_t lena, texta[lena] = '\0'; textb[lenb] = '\0'; - diff = strverscmp (texta, textb); + diff = filevercmp (texta, textb); texta[lena] = sv_a; textb[lenb] = sv_b; -- 1.5.4.1
_______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils