Mercurial > hg > octave-lyh > gnulib-hg
changeset 11266:98bcf3f48aa7
filevercmp: Move hidden files up in ordering.
author | Kamil Dudka <kdudka@redhat.com> |
---|---|
date | Thu, 05 Mar 2009 22:56:29 +0100 |
parents | abf535c3fafd |
children | a13a043d16f5 |
files | ChangeLog NEWS lib/filevercmp.c tests/test-filevercmp.c |
diffstat | 4 files changed, 30 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-03-05 Kamil Dudka <kdudka@redhat.com> + + * lib/filevercmp.c: Move hidden files up in ordering. + * tests/test-filevercmp.c: Add tests for hidden files. + 2009-03-04 Bruno Haible <bruno@clisp.org> * modules/visibility (Makefile.am): Augment AM_CFLAGS.
--- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ Date Modules Changes +2009-03-05 filevercmp Move hidden files up in ordering. + 2009-01-22 c-strtod This function no longer calls xalloc_die(). If c-strtold you want to exit the program in case of out-of- memory, the calling function needs to arrange
--- a/lib/filevercmp.c +++ b/lib/filevercmp.c @@ -124,8 +124,8 @@ int filevercmp (const char *s1, const char *s2) { - const char *s1_pos = s1; - const char *s2_pos = s2; + const char *s1_pos; + const char *s2_pos; const char *s1_suffix, *s2_suffix; size_t s1_len, s2_len; int result; @@ -135,7 +135,18 @@ if (simple_cmp == 0) return 0; + /* handle hidden files */ + while (*s1 == '.' || *s2 == '.') + { + if (*s1 != *s2) + return *s1 - *s2; + s1++; + s2++; + } + /* "cut" file suffixes */ + s1_pos = s1; + s2_pos = s2; s1_suffix = match_suffix (&s1_pos); s2_suffix = match_suffix (&s2_pos); s1_len = (s1_suffix ? s1_suffix : s1_pos) - s1;
--- a/tests/test-filevercmp.c +++ b/tests/test-filevercmp.c @@ -37,6 +37,16 @@ /* set of well sorted examples */ static const char *const examples[] = { + ".", + "..", + ".a~", + ".a", + ".b~", + ".b", + "a~", + "a", + "b~", + "b", "gcc-c++-10.fc9.tar.gz", "gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2", "glibc-2-0.1.beta1.fc10.rpm",